package gang.org.springframework.framework.factory.annotation;

import gang.org.springframework.framework.bean.GangRootBeanDefinition;

import java.util.Collection;
import java.util.Collections;

/**
 * 类说明：gang.chen springboot深度实践
 *
 * @author gang.chen
 * @since 2022/5/12
 */
public class GangInjectionMetadata {

    public final Class<?> targetClass;

    public final Collection<GangInjectedElement> injectedElements;

    public GangInjectionMetadata(Class<?> targetClass, Collection<GangInjectedElement> injectedElements) {
        this.targetClass = targetClass;
        this.injectedElements = injectedElements;
    }

    public static final GangInjectionMetadata empty = new GangInjectionMetadata(Object.class, Collections.emptyList()){
        @Override
        public boolean needsRefresh(Class<?> clazz) {
            return false;
        }

        @Override
        public void checkConfigMembers(GangRootBeanDefinition beanDefinition) {

        }

        @Override
        public void inject(Object target, String beanName, Object pvs) {

        }

        @Override
        public void clear(Object pvs) {

        }
    };


    public boolean needsRefresh(Class<?> clazz){
        return this.targetClass != clazz;
    }

    public void checkConfigMembers(GangRootBeanDefinition beanDefinition){

    }

    public void inject(Object target, String beanName, Object pvs){

    }

    public void clear(Object pvs){

    }


    public abstract static class GangInjectedElement{

    }
}
